﻿using ConfExpert.Forms.Base;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevTeam;

namespace ConfExpert.Forms.Depo.Kauf
{
    public partial class BirimMetrajlar : XForm
    {

        private int CustomerId { get; set; }
        public BirimMetrajlar(int CustomerId)
        {
            InitializeComponent();
            this.CustomerId = CustomerId;
        }

        private void BirimMetrajlar_Load(object sender, EventArgs e)
        {
            string customer = ConfExpert.Utility.AppSession.Lookups.V_Customer.FindByCustomerId(CustomerId).Name;
            this.Text = customer + " Birim Metrajlar";
            txtInfo.Caption = customer; 

            gvBM.Init("GetOrdersBM", CustomerId, cbTumu.Checked);

            gvBM.FormatAsNumber(1, "PastalG1", "PastalG2", "PastalG3", "PastalG4", "PastalG5", "PastalG6", "TahminiG1", "TahminiG2", "TahminiG3", "TahminiG4", "TahminiG5", "TahminiG6");
            gvBM.FormatAsNumber(2, "TahminiBM", "PastalBM");

            bbiGuncelle.ItemClick += bbiGuncelle_ItemClick;
            cbTumu.CheckedChanged += cbTumu_CheckedChanged;

            gvBM.AddSummary();
            gvBM.BestFitColumns();
        }

        void cbTumu_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            bbiGuncelle.PerformClick();
        }

        void bbiGuncelle_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            gvBM.RefreshDataSource("GetOrdersBM", CustomerId, cbTumu.Checked);
            gvBM.BestFitColumns();
        }

    }
}
